package com.ylp.lianxi.myChainOfResponsibility;

/**
 * 责任链模式
 * 
 * @author Administrator
 *
 */
public class ZMainTest {

	public static int DEBUG = 3;
	public static int INFO = 2;
	public static int ERROR = 1;
	
	// 工厂方式获取打印类
	// TODO:此处应该提取出来新建一个工厂类；
	public static AbstractLogger getLogger() {
		AbstractLogger errorer = new ErrorLogger();
		AbstractLogger filer = new FileLogger();
		AbstractLogger console = new ConsoleLogger();
		errorer.setNextLogger(filer);
		filer.setNextLogger(console);
		// 返回范围权限最小的error；
		return errorer;
	}

	// console > file > error
	public static void main(String[] args) {
		AbstractLogger logger = getLogger();
		logger.write(DEBUG, "你好-DEBUG");
		logger.write(INFO, "你好-INFO");
		logger.write(ERROR, "你好-ERROR");
		logger.write(4, "你好-4");
	}

}
